package adapter;

import java.util.ArrayList;

import com.qzhy.female.R;

import Constant.Constance;
import activity.MineActivity;
import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import model.Fans;
import utils.UILUtils;

public class ReplyAdapter extends BaseAdapter{

	private Context context;
	private ViewHold viewHold;
	private ArrayList<Fans> mFans;

	public ReplyAdapter(Context context) {
		this.context = context;
		
	}
	public ReplyAdapter(Context context,ArrayList<Fans> mFans) {
		this.context = context;
		this.mFans = mFans;
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return mFans.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {
		if(convertView==null){
			convertView=View.inflate(context, R.layout.item_myfans, null);
			viewHold = new ViewHold();
			viewHold.ImgIcon=(ImageView) convertView.findViewById(R.id.img_icon);
			viewHold.TvName=(TextView) convertView.findViewById(R.id.tv_username);
			viewHold.RtlUser=(RelativeLayout) convertView.findViewById(R.id.rtl_user);
			convertView.setTag(viewHold);
		}else {
			viewHold = (ViewHold) convertView.getTag();
		}	
		viewHold = (ViewHold) convertView.getTag();
		viewHold.TvName.setText(mFans.get(position).getNickname());
		UILUtils.displayImageNoAnim(Constance.URL.IMG_BASE+"/"+mFans.get(position).getProfileImg(), viewHold.ImgIcon);
		viewHold.RtlUser.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent intent = new Intent(context,MineActivity.class);
				intent.putExtra(Constance.INTENT.USER_ID, mFans.get(position).getId());
				context.startActivity(intent);
			}
		});
		return convertView;
	}
	
	class ViewHold{
		ImageView ImgIcon;
		TextView TvName;
		RelativeLayout RtlUser;
	}

}
